<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="author" content="胡爱静">
    <title>简易选项卡</title>
    <style>
        * {
            box-sizing: border-box;
        }

        ul {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        .box {
            width: 400px;
            margin: 100px auto;
            border: 1px solid black;
            text-align: center;
        }

        .nav {
            display: flex;
            background-color: black;
        }
        .one{
            background-color: #666;
        }
        section{
              display: none;  
        }

        section:nth-child(1){
             display: block; 
        }  
    </style>
</head>

<body>
    <div class="box">
        <ul class="nav">
            <li>选项一</li>
            <li>选项二</li>
            <li>选项三 </li>
        </ul>
    <div class="box2">
         <section>
                <p>选项一</p>
                <p>选项一</p>
                <p>选项一</p>
                <p>选项一</p>
        </section>
        <section>
                <p>选项二</p>
                <p>选项二</p>
                <p>选项二</p>
                <p>选项二</p>
                <p>选项二</p>
                <p>选项二</p>
        </section>
        <section>
                <p>选项三</p>
                <p>选项三</p>
        </section>
    </div>
       
    </div>

    <script src="./jquery.js"></script>
</body>

</html>
<script>

    $('li').css({ 'padding': '10px 20px', 'color': 'white' });
    
        // li 的 索引值=$(this).index()
        // console.log($(this).index());
    $('.nav>li').mouseenter(function(){
        $(this).css('background-color', '#666')
               .siblings().css('background-color', 'black'); 
        $('section').eq($(this).index()).show().siblings().hide();
    });
    

</script>